package bishi.baidu;

import org.omg.CORBA.MARSHAL;

import java.util.*;

public class demo2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();
        int count1 = getCount(s1,s2);
        int count2 = getCount(s2,s1);
        System.out.println(Math.min(count1,count2));
    }

    public static int getCount(String a,String b) {
        int n = a.length();
        int m = b.length();
        int len = Math.min(m,n);
        for(int i = len;i >=0;i--) {
            if(i == 0) {
                return 0;
            }
            String sub1 = a.substring(n - i);
            String sub2 = b.substring(0,i);
            if(sub1.equals(sub2)) {
                return i;
            }
        }
        return 0;
    }
}
